from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select
from page.base_page_helin import BasePage

class AddgoodsClassPage(BasePage):
    # 进入添加商品类别页面的定位器，依次点击主页【admin】【系统设置】【模块字段设置】
    # 【产品字段设置】【特殊字段设置】【添加产品类别】
    admin_button_locator=(By.XPATH,'/html/body/div[1]/div/div/div[2]/ul[2]/li[6]/a')
    xtsz_button_locator=(By.LINK_TEXT,"系统设置")
    mkzdsz_button_locator=(By.LINK_TEXT,"模块字段设置")
    cpzdsz_button_locator=(By.LINK_TEXT,"产品字段设置")
    tjzd_button_locator=(By.LINK_TEXT,"特殊设置")
    tjcplb_button_locator=(By.LINK_TEXT,"添加产品类别")

    # 添加产品类别定位器
    tjcplb_name_locator=(By.ID,"name")
    tjcplb_lb_locator=(By.ID,"categoryList")
    tjcplb_ms_locator=(By.CSS_SELECTOR,"#dialog-message1 > form > div:nth-child(3) > div > textarea")
    tjcplb_qd_locator=(By.CSS_SELECTOR,"input[value=提交]")

    # 进入添加产品类别页面
    def click_admin(self):
        self.driver.find_element(*self.admin_button_locator).click()

    def click_xtsz(self):
        self.driver.find_element(*self.xtsz_button_locator).click()

    def click_mkzdsz(self):
        self.driver.find_element(*self.mkzdsz_button_locator).click()

    def click_cpzdsz(self):
        self.driver.find_element(*self.cpzdsz_button_locator).click()

    def click_tszd(self):
        self.driver.find_element(*self.tjzd_button_locator).click()

    def click_tjcplb(self):
        self.driver.find_element(*self.tjcplb_button_locator).click()

    # 添加产品
    def add_cplbnm(self,cplbnm):
        self.driver.find_element(*self.tjcplb_name_locator).send_keys(cplbnm)

    def add_cplbfl(self,cplbfl):
        fl_element = self.driver.find_element(*self.tjcplb_lb_locator)
        select = Select(fl_element)
        select.select_by_visible_text(cplbfl)

    def add_cplbms(self, cplbms):
        self.driver.find_element(*self.tjcplb_ms_locator).send_keys(cplbms)

    def add_cplbqd(self):
        self.driver.find_element(*self.tjcplb_qd_locator).click()
